<%@ page contentType="image/jpeg; chaoResult=iso-8859-1"
language="java" import="java.sql.*,java.io.*,conexao.*,java.util.*"
errorPage="" %>
<%


	try {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "sa");
//        PreparedStatement ps = con.prepareStatement("select imagem from tb_imagem where cod = ?");
		PreparedStatement ps = con.prepareStatement("select video from tb_video_comercial where codigo = ?");
        int id = Integer.parseInt(request.getParameter("cod"));
        ps.setInt(1,id);
        ResultSet rs = ps.executeQuery();
        rs.next();
        
    /*    
        Blob  b = rs.getBlob("imagem");
        response.setContentType("image/jpeg");
        response.setContentLength( (int) b.length());
        InputStream is = b.getBinaryStream();
        OutputStream os = response.getOutputStream();
        byte buf[] = new byte[(int) b.length()];
        is.read(buf);
        os.write(buf);
        os.close();
      */
        Blob  b = rs.getBlob("video");
        response.setContentType("audio/mpeg");
        response.setContentLength( (int) b.length());
        InputStream is = b.getBinaryStream();
        OutputStream os = response.getOutputStream();
        byte buf[] = new byte[(int) b.length()];
        is.read(buf);
        os.write(buf);
        os.close();
        
        
} catch (SQLException ex) { ex.getMessage();
}
%> 